home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Programming / revolutionosx.sit / Revolution 1.1.1 / External SDK / XtTemplate.c < prev   
Encoding:
C/C++ Source or Header  |  2001-12-21  |  2.2 KB  |  97 lines  |  [????/????]

  1. /********************************************/
  2. /*    Copyright 1997 MetaCard Corporation   */
  3. /*    All Rights Reserved                   */
  4. /********************************************/
  5. /*
  6.   Template for Xt application calling MetaCard
  7. */
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #ifdef SELECT
  11. #ifndef LINUX
  12. /* some systems don't have select.h and/or stream.h.  If yours doesn't
  13.    delete the offending #include */
  14. #include <sys/select.h>
  15. #include <sys/stream.h>
  16. #endif
  17. #else
  18. #include <poll.h>
  19. #endif
  20. #include <X11/Xlib.h>
  21. #include <X11/Xatom.h>
  22. #include <X11/Intrinsic.h>
  23. #include <X11/Shell.h>
  24. #include <Xm/RowColumn.h>
  25. #include <Xm/PushB.h>
  26. #include <Xm/Xm.h>
  27.  
  28. #include "XCmdGlue.h"
  29.  
  30. Bool quittime = False;
  31.  
  32. #ifdef __STDC__
  33. void help(Widget w, XtPointer client_data, XtPointer call_data)
  34. #else
  35. void help(w, client_data, call_data)
  36.     Widget w;
  37.     XtPointer client_data;
  38.     XtPointer call_data;
  39. #endif
  40. {
  41.   int retval;
  42.  
  43.   printf("help callback\n");
  44.   SendCardMessage(istrdup("go to stack \"XT Help Demo\" as modeless"),
  45.           &retval);
  46.   printf("help callback done, retval was %d\n", retval);
  47. }
  48.  
  49. #ifdef __STDC__
  50. void quit(Widget w, XtPointer client_data, XtPointer call_data)
  51. #else
  52. void quit(w, client_data, call_data)
  53.     Widget w;
  54.     XtPointer client_data;
  55.     XtPointer call_data;
  56. #endif
  57. {
  58.   quittime = True;
  59. }
  60.  
  61. #ifdef __STDC__
  62. void main(int argc, char *argv[])
  63. #else
  64. void main(argc, argv)
  65.     int argc;
  66.     char *argv[];
  67. #endif
  68. {
  69.     Widget psMain;
  70.     Widget rcMain;
  71.     Widget pbHelp;
  72.     Widget pbQuit;
  73.     XtAppContext context;
  74.     XEvent event;
  75.     
  76.     psMain = XtVaAppInitialize(&context, "XT", NULL, 0, &argc, argv,
  77.                    NULL, NULL);
  78.     rcMain = XmCreateRowColumn(psMain, "rcMain", NULL, 0);
  79.     pbHelp = XmCreatePushButton(rcMain, "Help", NULL, 0);
  80.     XtManageChild(pbHelp);
  81.     pbQuit = XmCreatePushButton(rcMain, "Quit", NULL, 0);
  82.     XtManageChild(pbQuit);
  83.     XtManageChild(rcMain);
  84.     XtRealizeWidget(psMain);
  85.     XtAddCallback(pbHelp, XmNactivateCallback, help, NULL);
  86.     XtAddCallback(pbQuit, XmNactivateCallback, quit, NULL);
  87.     mc_xtinit(psMain, "mcXThelp.mc");
  88.     while (!quittime) {
  89.     XtAppNextEvent(context, &event);
  90.     XtDispatchEvent(&event);
  91.     }
  92.     XtUnmanageChild(rcMain);
  93.     XtDestroyWidget(psMain);
  94.     mc_xtclose();
  95.     exit(0);
  96. }
  97.